//
//  NavigationBar.m
//  项目三
//
//  Created by rimi1 on 2016/12/7.
//  Copyright © 2016年 Wangxingqian. All rights reserved.
//

#import "NavigationBar.h"

static NSInteger spacing_ = 20;
static NSInteger height = 44;

@implementation NavigationBar

- (instancetype)initWithFrame:(CGRect)frame {
    self = [super initWithFrame:frame];
    if (self) {
        [self addSubview:self.left];
        [self addSubview:self.title];
        [self addSubview:self.right];
    }
    return self;
}

#pragma mark - get

- (UIButton *)left {
    
    if (!_left) {
        
        _left = [[UIButton alloc] initWithFrame:CGRectMake(spacing_/2, spacing_, height, height)];
        [_left setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
        
    }
    return _left;
}

- (UILabel *)title {
    
    if (!_title) {
        
        _title = [[UILabel alloc] initWithFrame:CGRectMake(CGRectGetMaxX(self.left.frame), spacing_, kWIDTH - spacing_ - height * 2, height)];
        _title.textAlignment = NSTextAlignmentCenter;
        _title.textColor = [UIColor whiteColor];
        
    }
    return _title;
}

- (UIButton *)right {
    
    if (!_right) {
        
        _right = [[UIButton alloc] initWithFrame:CGRectMake(kWIDTH - spacing_/2 - height, spacing_, height, height)];
        [_right setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
        _right.titleLabel.textAlignment = NSTextAlignmentRight;
        
    }
    return _right;
}

@end











